import store from '@/store'

export default {
  bind(el, binding, vnode) {
    /** 当前页面路由信息无按钮，则隐藏 **/
    let btnArr = store.state.permission.btn;
    if(!btnArr || !(btnArr instanceof Array) || btnArr.length == 0){
      el.style.display = 'none';
      return
    }
    /** 使用此指令不传入值，或者传入空数组，或者传入非数组，隐藏 **/
    if(!binding.value || !(binding.value instanceof Array) || binding.value.length == 0){
      el.style.display = 'none';
      return
    }
    /** 路由按钮与指令按钮无交集，隐藏 **/
    let arr = binding.value.filter(val => btnArr.includes(val));
    if(!arr || arr.length == 0){
      el.style.display = 'none';
    }
  }
}
